package awt;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Demo4 extends JFrame {
	int size = 9;
	JButton jb[] = new JButton[size];

	public Demo4() {
		this.setLayout(new GridLayout(3, 3, 10, 10));

		for (int i = 0; i < size; i++) {
			jb[i] = new JButton("" + i);
			this.add(jb[i]);
		}

		this.setTitle("网格布局");
		this.setSize(200, 300);
		this.setLocation(100, 200);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);

	}

	public static void main(String[] args) {
		Demo4 demo4 = new Demo4();

	}

}
